<?php
/**
 * YLockBackendInterface.php
 *
 * @author Hua Yang <htmlcook@gmail.com>
 * @since 2.0
 */

/**
 * Interface LockBackendInterface
 */
interface YLockBackendInterface
{
	/**
	 * @param string $name
	 * @param float $timeout
	 * @return bool
	 */
	public function acquire($name, $timeout = 30.0);

	/**
	 * @param string $name
	 * @return bool
	 */
	public function lockMayBeAvailable($name);

	/**
	 * @param string $name
	 * @param int $delay
	 * @return bool
	 */
	public function wait($name, $delay = 30);

	/**
	 * @param string $name
	 */
	public function release($name);

	/**
	 * @param string $lockId
	 */
	public function releaseAll($lockId = null);

	/**
	 * @return string
	 */
	public function getLockId();
}